/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/rng/fortuna/fnaCounter.cpp,v 1.4 2003/11/21 16:12:58 itsme Exp $
 *
 *
 * Design of the PRNG is literally taken from 'Practical Cryptography', by Niels Ferguson, and Bruce Schneier.
 *
 */


#include "fnaCounter.h"
#include "vectorutils.h"

//--------------------------------------------------------------------------
//------------------counter handling----------------
void Counter::Clear()
{
    m_value.clear();
    m_value.resize(COUNTERSIZE);
}
void Counter::Increment()
{
    for (ByteVector::iterator i= m_value.begin() ; i!=m_value.end() ; ++i)
    {
        if (++(*i))
            break;
    }
}
bool Counter::IsZero() const
{
    for (ByteVector::const_iterator i= m_value.begin() ; i!=m_value.end() ; ++i)
    {
        if (*i)
            return false;
    }
    return true;
}

const ByteVector& Counter::GetValue() const
{
    return m_value;
}
